<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="channelProcessingFilter"
          class="org.acegisecurity.securechannel.ChannelProcessingFilter">
        <property name="channelDecisionManager">
            <ref local="channelDecisionManager"/>
        </property>
        <property name="filterInvocationDefinitionSource">
            <value>
                CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                PATTERN_TYPE_APACHE_ANT
                /j_acegi_security_check=REQUIRES_CAPTCHA_ONCE_ABOVE_THRESOLD_REQUESTS
            </value>
        </property>
    </bean>
    <!-- 如果需要附加码验证，则/j_acegi_security_check=REQUIRES_CAPTCHA_ONCE_ABOVE_THRESOLD_REQUESTS -->

    <bean id="channelDecisionManager"
          class="org.acegisecurity.securechannel.ChannelDecisionManagerImpl">
        <property name="channelProcessors">
            <list>
                <ref local="testOnceAfterMaxRequestsCaptchaChannelProcessor"/>
                <ref local="alwaysTestAfterTimeInMillisCaptchaChannelProcessor"/>
                <ref local="alwaysTestAfterMaxRequestsCaptchaChannelProcessor"/>
                <ref local="alwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor"/>
            </list>
        </property>
    </bean>

    <!-- REQUIRES_CAPTCHA_ONCE_ABOVE_THRESOLD_REQUESTS -->
    <bean id="testOnceAfterMaxRequestsCaptchaChannelProcessor"
          class="org.acegisecurity.captcha.TestOnceAfterMaxRequestsCaptchaChannelProcessor">
        <property name="thresold">
            <value>0</value>
        </property>
        <property name="entryPoint">
            <ref bean="captchaEntryPoint"/>
        </property>
    </bean>

    <!-- REQUIRES_CAPTCHA_ABOVE_THRESOLD_REQUESTS -->
    <bean id="alwaysTestAfterMaxRequestsCaptchaChannelProcessor"
          class="org.acegisecurity.captcha.AlwaysTestAfterMaxRequestsCaptchaChannelProcessor">
        <property name="thresold">
            <value>5</value>
        </property>
        <property name="entryPoint">
            <ref bean="captchaEntryPoint"/>
        </property>
    </bean>

    <!-- REQUIRES_CAPTCHA_AFTER_THRESOLD_IN_MILLIS -->
    <bean id="alwaysTestAfterTimeInMillisCaptchaChannelProcessor"
          class="org.acegisecurity.captcha.AlwaysTestAfterTimeInMillisCaptchaChannelProcessor">
        <property name="thresold">
            <value>5000</value>
        </property>
        <property name="entryPoint">
            <ref bean="captchaEntryPoint"/>
        </property>
    </bean>

    <!-- REQUIRES_CAPTCHA_BELOW_AVERAGE_TIME_IN_MILLIS_REQUESTS -->
    <bean
            id="alwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor"
            class="org.acegisecurity.captcha.AlwaysTestBelowAverageTimeInMillisBetweenRequestsChannelProcessor">
        <property name="thresold">
            <value>20000</value>
        </property>
        <property name="entryPoint">
            <ref bean="captchaEntryPoint"/>
        </property>
    </bean>

    <bean id="captchaEntryPoint"
          class="org.acegisecurity.captcha.CaptchaEntryPoint">
        <property name="captchaFormUrl">
            <value>/login/login.jsp?login_error=code_error</value>
        </property>
        <property name="includeOriginalRequest">
            <value>false</value>
        </property>
        <property name="includeOriginalParameters">
            <value>false</value>
        </property>
    </bean>

    <bean id="captchaValidationProcessingFilter"
          class="org.acegisecurity.captcha.CaptchaValidationProcessingFilter">
        <property name="captchaService">
            <ref bean="captchaService"/>
        </property>
        <property name="captchaValidationParameter">
        	<value>j_captcha_response</value>
        </property>
    </bean>

    <!-- imageCaptchaService is injected into captchaImageCreateController as well as to captchaService beans -->
    <bean id="captchaService" class="org.springside.modules.security.jcaptcha.JCaptchaServiceProxyImpl">
        <property name="jcaptchaService" ref="imageCaptchaService"/>
    </bean>

    <bean id="imageCaptchaService" class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService">
        <constructor-arg type="com.octo.captcha.service.captchastore.CaptchaStore" index="0">
            <ref bean="fastHashMapCaptchaStore"/>
        </constructor-arg>
        
        <constructor-arg type="com.octo.captcha.engine.CaptchaEngine" index="1">
            <ref bean="defaultGimpyEngine"/>
        </constructor-arg>  
          
        <!--    
        <constructor-arg type="com.octo.captcha.engine.CaptchaEngine" index="1">
            <ref bean="SpringSideCaptchaEngineEx"/>
        </constructor-arg>        
		-->  
        <constructor-arg index="2">
            <value>180</value>
        </constructor-arg>
        <constructor-arg index="3">
            <value>100000</value>
        </constructor-arg>
        <constructor-arg index="4">
            <value>75000</value>
        </constructor-arg>
    </bean>

    <bean id="fastHashMapCaptchaStore" class="com.octo.captcha.service.captchastore.FastHashMapCaptchaStore"/>

    <bean id="defaultGimpyEngine" class="org.springside.modules.security.jcaptcha.engine.SpringSideCaptchaEngine"/>
    
	<bean id="SpringSideCaptchaEngineEx" class="org.springside.modules.security.jcaptcha.engine.SpringSideCaptchaEngineEx"/>    

</beans>
